<?php

/**
 * Affiche la liste des messages du membre
 */

require('config.php');
$format = Annuaire::lookup(KEY_FORMAT);

if(!isset($_SESSION['id_user'])){
    redirectFront('connexion');
}

//$_SESSION['new_message'] = modelUser::hasNewMessage($_SESSION['id_user']);


$page = new rootLayoutCategory();
$page->setBaliseTitle('profil_mes_factures_balise');
$page->setDescription('profil_mes_factures_balise_description');

//-- menu Left show products--------------------------------//
$menu = new layoutMenu();
$menuCategorie = new layoutMenuCategorie();
$menu->pushMenu($menuCategorie);
$menuPage = new layoutMenuPage();
$menu->pushMenu($menuPage);
$page->setMenu($menu);
//-- corps de la page --------------------------------------------------------//
$tpl_file='profil-mes-factures.tpl';
$profil_mes_factures = new flyLayout(REP_TPL . $tpl_file);
$profil_mes_factures->start();

$tabs = new layoutTabs();
$tabs->pushLink('Mon compte', '/profil.php');
$tabs->pushLink('Mes messages', '/profil-message.php');
$tabs->pushLink('Mes factures', '/profil-mes-factures.php');
$profil_mes_factures->includeLayout('tabs', $tabs);

$server_name = $_SERVER['SERVER_NAME'];

$listPdf= modelUploadFile::getListPdfByUserId($_SESSION['id_user']);
if($listPdf->nextObject()){
	foreach($listPdf as $key => $pdf) {
		$profil_mes_factures->setVariable('name_pdf',$pdf->nom_serveur);

		$link_to_pdf_file = "http://$server_name/".$pdf->url_repertoire.$pdf->nom_serveur;
		$profil_mes_factures->setVariable('url_pdf_file',$link_to_pdf_file);

		$profil_mes_factures->setVariable('date_pdf', 'Le '.$format->out($pdf->date_modification, Format::DATE). utf8_encode(' � ').$format->out($pdf->date_modification, Format::TIME));
	    $profil_mes_factures->parseList('list_pdf');
	}
	$profil_mes_factures->showBlock('invoices');
}
else{
	$profil_mes_factures->showBlock('nothing');
}

$profil_mes_factures->stop();

$page->setBody($profil_mes_factures);
//----------------------------------------------------------------------------//

$page->display();


?>